//
//  DKLoginChangeLoginTypeView.m
//  DanKU
//
//  Created by 吴斌 on 2023/9/20.
//

#import "DKLoginChangeLoginTypeView.h"
@interface DKLoginChangeLoginTypeView()
@property (nonatomic, strong)UIButton * dk_PwdLoginTypeBtn;
@property (nonatomic, strong)UIButton * dk_CaptchaLoginTypeBtn;
@end
@implementation DKLoginChangeLoginTypeView
-(instancetype)init{
    if(self == [super init]){
        self.backgroundColor = UIColor.clearColor;
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    //pwdLogin
    self.dk_PwdLoginTypeBtn = [[UIButton alloc] init];
    [self.dk_PwdLoginTypeBtn setTitle:@"Password login" forState:UIControlStateNormal];
    [self.dk_PwdLoginTypeBtn setTitleColor:DK_Hex(@"#CCCCCC") forState:UIControlStateNormal];
    [self.dk_PwdLoginTypeBtn setTitleColor:DK_Hex(@"#333333") forState:UIControlStateSelected];
    self.dk_PwdLoginTypeBtn.titleLabel.font = DK_FONT_Medium(17);
    self.dk_PwdLoginTypeBtn.tag = 100;
    [self.dk_PwdLoginTypeBtn addTarget:self action:@selector(changePwdLogin:) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.dk_PwdLoginTypeBtn];
    [self.dk_PwdLoginTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(30)));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
    //Captchalogin
    self.dk_CaptchaLoginTypeBtn = [[UIButton alloc] init];
    [self.dk_CaptchaLoginTypeBtn setTitle:@"Captcha login" forState:UIControlStateNormal];
    [self.dk_CaptchaLoginTypeBtn setTitleColor:DK_Hex(@"#CCCCCC") forState:UIControlStateNormal];
    [self.dk_CaptchaLoginTypeBtn setTitleColor:DK_Hex(@"#333333") forState:UIControlStateSelected];
    self.dk_CaptchaLoginTypeBtn.titleLabel.font = DK_FONT_Medium(17);
    self.dk_CaptchaLoginTypeBtn.tag = 101;
    [self.dk_CaptchaLoginTypeBtn addTarget:self action:@selector(changeCaptchaLogin) forControlEvents:UIControlEventTouchUpInside];
    [self addSubview:self.dk_CaptchaLoginTypeBtn];
    [self.dk_CaptchaLoginTypeBtn mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_PwdLoginTypeBtn.mas_right).offset(DK_IsWidthScale(10));
        make.top.equalTo(@(DK_IsWidthScale(0)));
        make.bottom.equalTo(@(DK_IsWidthScale(0)));
    }];
}
- (void)defaltInit{
    [self changePwdLogin:self.dk_PwdLoginTypeBtn];
}
- (void)changePwdLogin:(UIButton *)sender{
    self.dk_PwdLoginTypeBtn.selected = YES;
    self.dk_CaptchaLoginTypeBtn.selected = NO;
    if(self.changeLoginTypeBlock){
        self.changeLoginTypeBlock((int)self.dk_PwdLoginTypeBtn.tag);
    }
}
- (void)changeCaptchaLogin{
    self.dk_CaptchaLoginTypeBtn.selected = YES;
    self.dk_PwdLoginTypeBtn.selected = NO;
    if(self.changeLoginTypeBlock){
        self.changeLoginTypeBlock((int)self.dk_CaptchaLoginTypeBtn.tag);
    }
}
@end
